<template>
    <div class="bank-list">
        <ul>
            <li v-for="(item,index) in items">
                <div class="btn">
                    <yd-button type="primary" v-if="item.isDefault!=1" @click.native="setDefault(item.tag)">设置为默认账户
                    </yd-button>
                    <yd-button type="primary" @click.native="del(item.tag)">删除</yd-button>
                </div>
                <div class="bank-info">
                    <p>{{item.bankName}}</p>
                    <p>{{item.bankAccountID}}</p>
                    <p>{{item.bankUserName}}</p>
                    <img src="../../images/account/bank_bg.png">
                </div>
            </li>
            <!--<li>
                <div class="bank-info">
                    <img src="../../images/account/add_bank.png">
                </div>
            </li>-->
        </ul>
    </div>
</template>
<script>
    import AjaxHttp from '../../js/ajaxHttp.js';
    import Tools from '../../js/tools.js';
    import Config from '../../js/config.js';
    export default{
        data: function () {
            return {
                items: ''
            }
        },
        created: function () {
            this.getBank();
        },
        methods: {
            getBank: function () {
                const _this = this;
                AjaxHttp.getHttp('fxsys/userInfo/myBankAccount').then(function (response) {
                    console.log(response);
                    _this.items = response.mtBankAccountInitVOList;
                });
            },
            del: function (tag) {
                console.log(tag);
                const _this = this;
                const params = {
                    tag: tag
                };
                _this.$dialog.confirm({
                    title: '确认删除此银行卡？',
                    opts: function () {
                        AjaxHttp.getHttp('fxsys/userInfo/deleteBank', params).then(function (response) {
                            console.log(response);
                            _this.getBank();
                        });
                    }
                });
            },
            setDefault: function (tag) {
                console.log(tag);
                const _this = this;
                const params = {
                    tag: tag
                };
                _this.$dialog.confirm({
                    title: '确认设置此银行卡为默认银行卡？',
                    opts: function () {
                        AjaxHttp.getHttp('fxsys/userInfo/setDefaultBank', params).then(function (response) {
                            _this.getBank();
                        });
                    }
                });
            }
        }
    }
</script>